package com.jzo2o.foundations.controller.consumer;

import com.jzo2o.api.foundations.dto.response.ServeItemResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.model.dto.response.ServeSimpleResDTO;
import com.jzo2o.foundations.service.HomeService;
import com.jzo2o.foundations.service.ServeAggregationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

//门户查询缓存类的接口1 我的  刚才还可以推送 然后不知道就不行了
@RestController("consumerServeController")
@RequestMapping("/customer/serve")
@Api(tags = "用户端-首页服务查询接口")
public class FirsPageServeController {
    @Resource
    private HomeService homeService;
    @Resource
    private ServeAggregationService serveAggregationService;
    @GetMapping("/firstPageServeList")
    @ApiOperation("首页服务列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "regionId", value = "区域id", required = true, dataTypeClass = Long.class)
    })
        public List<ServeCategoryResDTO> serveCategory(@RequestParam("regionId") Long regionId){
        //调用Service
        List<ServeCategoryResDTO> serveCategoryResDTOS = homeService.queryServeIconCategoryByRegionIdCache(regionId);

        return serveCategoryResDTOS;
    }
    @GetMapping("/serveTypeList")
    @ApiOperation("全部服务列表")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "regionId", value = "区域id", required = true, dataTypeClass = Long.class)
    )
    public List<ServeCategoryResDTO> serveCategoryResDTOSAll(@RequestParam("regionId") Long regionId){
        //调用Service
        List<ServeCategoryResDTO> list = homeService.queryServeIconCategoryByRegionIdAll(regionId);
        return list;
    }
    @GetMapping("/hotServeList")
    @ApiOperation("首页热门服务列表")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "regionId", value = "区域id", required = true, dataTypeClass = Long.class)
    )//ServeAggregationSimpleResDTO
    public   List<ServeAggregationSimpleResDTO> hotServeList(@RequestParam("regionId") Long regionId){
        List<ServeAggregationSimpleResDTO> list=homeService.hotServeList(regionId);
          return list;
    }
    @GetMapping("/{id}")
    @ApiOperation("根据id查询服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class)
    })
    public ServeAggregationSimpleResDTO serveById(@PathVariable("id") Long id){

        return homeService.serveById(id);
    }

    @GetMapping("/search")
    @ApiOperation("首页服务搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cityCode", value = "城市编码", required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "serveTypeId", value = "服务类型id", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "keyword", value = "关键词", dataTypeClass = String.class)
    })
    public List<ServeSimpleResDTO> findServeList(@RequestParam("cityCode") String cityCode,
                                                 @RequestParam(value = "serveTypeId", required = false) Long serveTypeId,
                                                 @RequestParam(value = "keyword", required = false) String keyword) {
        List<ServeSimpleResDTO> serveList = serveAggregationService.findServeList(cityCode, serveTypeId, keyword);
        return serveList;
    }
}
